// 获取应用实例
const app = getApp()
// 引入http.js
const http = require('../../utils/http')

Page({
  data: {
    notebookList: [],
    pagination: [{
      text: "10条",
      value: 10
    }, {
      text: "20条",
      value: 20
    }, {
      text: "50条",
      value: 30
    }, {
      text: "100条",
      value: 100
    }],
    pagination_index: 0,
    slid_buttons: [{
      type: "warn",
      text: "删除"
    }, {
      type: "default",
      text: "修改"
    } ]
  },
  onLoad() {
  },
  onShow() {
    // TODO 获取用户的notebook
    http.get({
      url: "/notebook/getUserNotebook",
      data: {pk_user: app.globalData.pk_user},
      successCallback: (res) => {
        this.setData({
          notebookList: res.data.notebookList
        })
        

      }
    })
  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      pagination_index: e.detail.value
    })
  },
  addNotebook: function() {
    wx.navigateTo({
      url: '../addOrUpdate/addOrUpdate'
    })
  },
  showDetail: function(e) {
    // 获取点击的笔记的 pk_notebook
    let pk_notebook = e.currentTarget.dataset.pk_notebook;
    // 带主键跳转
    wx.navigateTo({
      url: '../addOrUpdate/addOrUpdate?pk_notebook=' + pk_notebook,
    })
  }
})